﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CustomizePDF.MyDialog
{
    public partial class SizeDialog : Form
    {
        public string WidthValue { get; private set; }
        public string HeightValue { get; private set; }
        public SizeDialog()
        {
            InitializeComponent();
        }
        public void Init()
        {
        }

        private void SizeDialogConfirmBtn_Click(object sender, EventArgs e)
        {
            //匹配整数或浮动数字
            string pattern = @"^[-+]?[0-9]*\.?[0-9]+$";
            if (string.IsNullOrEmpty(this.SizeDialogWidthVal.Text)|| !Regex.IsMatch(this.SizeDialogWidthVal.Text,pattern))
            {
                MessageBox.Show("请输入数字，并且不为空");
                return;
            }
            if (string.IsNullOrEmpty(this.SizeDialogHeightVal.Text) || !Regex.IsMatch(this.SizeDialogHeightVal.Text, pattern))
            {
                MessageBox.Show("请输入数字，并且不为空");
                return;
            }
            WidthValue = this.SizeDialogWidthVal.Text;
            HeightValue = this.SizeDialogHeightVal.Text;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
